package com.bluesky.jwf.component.validator;

import com.bluesky.javawebbrowser.domain.html.tags.Tag;
import com.bluesky.jwf.component.list.ListItem;

public class MessageListItem extends ListItem {

	protected Tag messageTag;
	private String messageTemplate;

	@Override
	public void init(String html) {

		super.init(html);

		messageTag = loadByJwfClass("message");

		messageTemplate = messageTag.toHtml();

	}

	@Override
	public void setModel(Object model) {
		super.setModel(model);

		Validator v = (Validator) model;

		messageTag.setBodyAndParse(v.getMessage());

		if (!v.getResult())
			messageTag.setStyleAttribute("color", "red");
		else
			messageTag.removeStyleAttribute("color");
	}
}
